﻿using SD.Infrastructure.EntityBase;
using System;
using System.Text;

namespace SlamDunk.MES.Domain.Entities.MaintenanceContext
{
    /// <summary>
    /// 设备维护类
    /// </summary>
    public class EquipmentMaintainClass : AggregateRootEntity
    {
        #region # 构造器

        #region 00.无参构造器
        /// <summary>
        /// 无参构造器
        /// </summary>
        protected EquipmentMaintainClass() { }
        #endregion

        #region 01.创建设备维护类构造器
        /// <summary>
        /// 创建设备维护类构造器
        /// </summary>
        /// <param name="classNo">维护类编号</param>
        /// <param name="className">维护类名称</param>
        /// <param name="maintainedContent">维护内容</param>
        /// <param name="maintainedInterval">维护周期</param>
        /// <param name="maintainedPrincipal">维护负责人</param>
        /// <param name="facilityId">工厂模型Id</param>
        /// <param name="description">描述</param>
        public EquipmentMaintainClass(string classNo, string className, string maintainedContent, string maintainedInterval, string maintainedPrincipal, Guid? facilityId, string description)
            : this()
        {
            base.Number = classNo;
            base.Name = className;
            this.MaintainedContent = maintainedContent;
            this.MaintainedInterval = maintainedInterval;
            this.MaintainedPrincipal = maintainedPrincipal;
            this.FacilityId = facilityId;
            this.Description = description;

            //初始化关键字
            this.InitKeywords();
        }
        #endregion

        #endregion

        #region # 属性

        #region 维护内容 —— string MaintainedContent
        /// <summary>
        /// 维护内容
        /// </summary>
        public string MaintainedContent { get; private set; }
        #endregion

        #region 维护周期 —— string MaintainedInterval
        /// <summary>
        /// 维护周期
        /// </summary>
        public string MaintainedInterval { get; private set; }
        #endregion

        #region 维护负责人 —— string MaintainedPrincipal
        /// <summary>
        /// 维护负责人
        /// </summary>
        public string MaintainedPrincipal { get; private set; }
        #endregion

        #region 工厂模型Id —— Guid? FacilityId 
        /// <summary>
        /// 工厂模型Id
        /// </summary>
        public Guid? FacilityId { get; private set; }
        #endregion

        #region 描述 —— string Description
        /// <summary>
        /// 描述
        /// </summary>
        public string Description { get; private set; }
        #endregion

        #endregion

        #region # 方法

        #region 修改设备维护类 —— void UpdateInfo(string classNo...
        /// <summary>
        /// 修改设备维护类
        /// </summary>
        /// <param name="classNo">维护类编号</param>
        /// <param name="className">维护类名称</param>
        /// <param name="maintainedContent">维护内容</param>
        /// <param name="maintainedInterval">维护周期</param>
        /// <param name="maintainedPrincipal">维护负责人</param>
        /// <param name="facilityId">工厂模型Id</param>
        /// <param name="description">描述</param>
        public void UpdateInfo(string classNo, string className, string maintainedContent, string maintainedInterval, string maintainedPrincipal, Guid? facilityId, string description)
        {
            base.Number = classNo;
            base.Name = className;
            this.MaintainedContent = maintainedContent;
            this.MaintainedInterval = maintainedInterval;
            this.MaintainedPrincipal = maintainedPrincipal;
            this.FacilityId = facilityId;
            this.Description = description;

            //初始化关键字
            this.InitKeywords();
        }
        #endregion

        #region 初始化关键字 —— void InitKeywords()
        /// <summary>
        /// 初始化关键字
        /// </summary>
        private void InitKeywords()
        {
            StringBuilder builder = new StringBuilder();
            builder.Append(base.Number);
            builder.Append(base.Name);
            builder.Append(this.MaintainedContent);
            builder.Append(this.Description);

            base.SetKeywords(builder.ToString());
        }
        #endregion

        #endregion
    }
}
